const source = require('../sources/a.json')
const { downloadChapter, parseChapter } = require('../modules/chapter')
const book = require('../temp/book.json')

downloadChapter(source, book.chapterUrl).then(res => {
  const chapter = parseChapter(source, res)
  require('fs').writeFile(__dirname + '/../temp/chapter.json', JSON.stringify(chapter), function (err) {
    console.log(err)
  })
}).catch(err => {
  console.log(err)
})

// require('fs').readFile(__dirname + '/../temp/chapter.html', function (err, data) {
//   const chapter = parseChapter(source, data.toString('utf8'))
//   console.log(chapter)
// })
